/**
 * 
 */
package idv.takeshi.software.productline.bookstore.domain.model.book;

import idv.takeshi.software.productline.bookstore.domain.model.useraccount.Publisher;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Set;

import org.apache.commons.lang.Validate;

/**
 * A model factory for Book.
 * @author takeshi
 *
 */
public class BookFactory {
	
	/**
	 * New a instance of Book by following given arguments.
	 * @param name
	 * @param fixedPrice
	 * @param publishDate
	 * @param locale
	 * @param isbn
	 * @param publisher
	 * @param authors
	 * @return
	 */
	public Book newInstance(String name, BigDecimal fixedPrice, Date publishDate, 
			String locale, String isbn, Publisher publisher, Set<Author> authors){
		Validate.notEmpty(name, "name shall always not be null/empty");
		Validate.notNull(fixedPrice, "fixedPrice shall always not be null");
		Validate.notNull(publishDate, "publishDate shall always not be null");
		Validate.notEmpty(locale, "locale shall always not be null/empty");
		Validate.notEmpty(isbn, "isbn shall always not be null/empty");
		Validate.notNull(publisher, "publisher shall always not be null");
		Validate.notEmpty(authors, "authors shall always not be null");
		
		Book book = new Book();
		book.setName(name);
		book.setFixedPrice(fixedPrice);
		book.setPublishDate(publishDate);
		book.setLocale(locale);
		book.setIsbn(isbn);
		book.setPublisher(publisher);
		book.setAuthors(authors);
		book.setInventory(new Inventory());
		
		return book;
	}
	
}
